home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************/
- /* */
- /* THE POOP SHELL */
- /* */
- /********************************************************************/
- /* An Adventure in Pseudo-Object-Oriented-Programming */
- /********************************************************************/
- /*
- * >>> File name: Main
- *
- * >>> Purpose: The main, start-up and shutdown routines
- * >>> Project: PoopDraw
- * >>> Date: June 5, 1989
- * >>> By: Adam Treister
- *
- */
- /********************************************************************/
- /* For Your Information 1802 Hillside Rd. SB CA 93101 */
- /********************************************************************/
-
- #include "PoopDrawInc"
-
- /********************************************************************/
-
- main (void);
- private void WakeUp (void);
- private void Die (void);
-
- foreign void Twiddle (void);
- foreign void ApplicationInit (void);
- foreign void ApplicationShutDown (void);
-
-
- /********************************************************************/
- /* THE GLOBAL DECLARATIONS */
- /********************************************************************/
-
- MenuHandle Menus[NUMMENUS];
- EventRecord Event; /* the Event Record */
- long LastMouseDown = 0; /* time of last mouse down */
- Boolean MillerTime = false; /* Quit flag */
- int errno;
-
- /* ------------------------------------------------------------ */
- /* */
- /* MAIN */
- /* */
- /* The standard shit - init, run, shutdown */
- /* */
- /* ------------------------------------------------------------ */
-
- main()
- {
- WakeUp();
- Twiddle();
- Die();
- }
-
- /* ------------------------------------------------------------ */
- /* */
- /* WAKE UP */
- /* */
- /* This function initialises the Mac Toolbox, creates the */
- /* menu bar and calls an application specific init routine */
- /* */
- /* ------------------------------------------------------------ */
-
-
- void WakeUp()
- {
- WindowPtr win;
- register int i;
- extern MenuHandle Menus[];
-
- InitMacintosh();
- TurnWatchOn();
-
- for (i=0; i < NUMMENUS; i++ )
- {
- Menus[i] = GetMenu(i + AppleMenuID-1);
- InsertMenu(Menus[i], 0);
- }
- AddResMenu(Menus[0],'DRVR');
- DrawMenuBar();
- HiliteMenu(0);
-
- ApplicationInit();
- TurnArrowOn();
- }
-
- /* ------------------------------------------------------------ */
- /* */
- /* DIE */
- /* */
- /* Tidys up everything before the application quits. */
- /* If there any windows open they are closed. */
- /* */
- /* ------------------------------------------------------------ */
-
- void Die()
- {
-
- Str255 message,ctStr,sizStr;
-
-
- while (MyFrontWindow())
- {
- WDispatch(MyFrontWindow(),CLOSE,NULL);
- }
- ApplicationShutDown();
- ExitToShell();
- }
- /*------------------------------------------------------------------*/
- /* send messages to the appropriate object
- /*------------------------------------------------------------------*/
- void Dispatch(ObjectH,Message,ParmP)
- ObjectHandle ObjectH;
- int Message;
- LPtr ParmP;
- {
- if (ObjectH)
- (*(*ObjectH)->dispatch)(ObjectH,Message,ParmP);
- }
- /*------------------------------------------------------------------*/
- /* A special case of Dispatch exclusively for windows.
- /*------------------------------------------------------------------*/
-
- void WDispatch(wP,Message,ParmP)
- WindowPtr wP;
- int Message;
- LPtr ParmP;
- {
- ObjectHandle obj;
- obj = (ObjectHandle) GetWRefCon(wP);
- if (obj) (*(*obj)->dispatch)(obj,Message,ParmP);
- }
-